from django.db import models


# Create your models here.
from login.models import User


class Comment(models.Model):
    name = models.CharField(max_length=200)
    email = models.EmailField(max_length=100)
    url = models.URLField(blank=True)
    text = models.TextField()
    created_time = models.DateTimeField(auto_now_add=True)
    post = models.ForeignKey('blog.Article', on_delete=models.CASCADE)
    # comment_user = models.ForeignKey(User, related_name='user', on_delete=models.CASCADE)  # 评论者
    # reply_user = models.ForeignKey('login.User', related_name='to_user', on_delete=models.CASCADE, null=True,default='')  # 回复者

    class Meta:
        verbose_name = '评论'
        verbose_name_plural = '评论'

    def __str__(self):
        return self.text[:20]
